<?php
if (isset($_POST['edit']))
{
$name=$_POST['tentb'];
$link=$_POST['linktb'];
$time=time();
$cmd="UPDATE `thongbao` SET `thongbao_text`='$name', `thongbao_link`='$link' WHERE `thongbao_id`=".$_GET['edit'];
mysql_query($cmd);
echo 'Đã sửa thông báo xong !';
} else
if (isset($_POST['add']))
{
$name=$_POST['tentb'];
$link=$_POST['linktb'];
$time=time();
$cmd="INSERT INTO `thongbao` (`thongbao_text`,`thongbao_link`,`thongbao_time`) VALUES ('$name','$link',$time)";
mysql_query($cmd);
$_POST['ađd']='';
echo 'Đã thêm 1 thông báo !';
} else
if (isset($_GET['act']))
{
echo '<form method="post" enctype="multipart/form-data">
Thông báo : <div class="selecttitle"><input type="text" name="tentb"></div>
Đường dẫn  : <div class="selecttitle"><input type="text" name="linktb"></div>
<input type="submit" class="buttonclick" value="Thêm" name="add"/>
</form>
';
} else
if (isset($_GET['edit']))
{

$sql="SELECT * FROM `thongbao` WHERE thongbao_id=".$_GET['edit'];
$info=mysql_fetch_assoc(mysql_query($sql));
echo '<form method="post" enctype="multipart/form-data">
Thông báo : <div class="selecttitle"><input type="text" name="tentb" value="'.$info['thongbao_text'].'"></div>
Đường dẫn  : <div class="selecttitle"><input type="text" name="linktb" value="'.$info['thongbao_link'].'"></div>
<input type="submit" class="buttonclick" value="Sửa" name="edit"/>
</form>
';
} else
{
if (isset($_GET['del']))
{
    $sql="DELETE FROM `thongbao` WHERE thongbao_id=".$_GET['del'];
	$excute=mysql_query($sql);	
}
echo '
<div id="space"><div class="buttons"><a href="?menu=module&config=27&act=add" class="button add">Thêm</a></div></div>
<div id="view">
<table width="775" border="1" class="view" cellpadding="10" cellspacing="0">
  <th width="30px">ID</th>
  <th>Thông báo</th>
  <th width="300px">Liên kết</th>
  <th width="50px">Sửa</th>
  <th width="50px">Xóa</th>';
	$sql="SELECT * FROM `thongbao`";
	$excute=mysql_query($sql);
	  while ($row=mysql_fetch_array($excute,MYSQL_ASSOC))
	  {
		  echo '<tr><td>'.$row['thongbao_id']; echo '</td>';
		  echo '<td>'.$row['thongbao_text']; echo '</td>';
		  echo '<td>'.$row['thongbao_link']; echo '</td>';
		  
echo '<td><div class="buttons"><a class="button flag" href="?menu=module&config=27&edit='.$row['thongbao_id'].'">Sửa</a></div></td>';
echo '<td><div class="buttons"><a class="button flag" href="?menu=module&config=27&del='.$row['thongbao_id'].'">Xóa</a></div></td>';
	  }
echo '</table></div>';
}
?>